import java.util.*;

public class Test {

    public static void main(String[] args) {
        Map<String, String> map = new TreeMap<>();
        map.put("1", "Lucy");
        map.put("3", "Smith");
        map.put("4", "Aimee");
        map.put("5", "Amanda");
        map.put("2", "John");

        System.out.println("排序前的键值对：");
        for (String key : map.keySet()) {
            System.out.println(key + "：" + map.get(key));
        }

        // 按自然顺序倒序排列
        map = new TreeMap<>(Collections.reverseOrder());
        map.put("1", "Lucy");
        map.put("3", "Smith");
        map.put("4", "Aimee");
        map.put("5", "Amanda");
        map.put("2", "John");

        System.out.println("排序后的键值对：");
        for (String key : map.keySet()) {
            System.out.println(key + "：" + map.get(key));
        }
    }
}
